<template>
    <div class="nowPlaying">
        <div v-for="item of movies" :key="item._id" class="item">
            <img class="pic" :src="item.pic" alt="" @click="handleDetail(item._id)">
            <div class="content">
                <div class="title">{{item.title}}</div>
                <div class="rating">观众评分 <span>{{item.rating}}</span></div>
                <div class="type">{{item.type}}</div>
            </div>
            <button class="btn">购票</button>
        </div>
    </div>
</template>

<script>
    export default {
        name:'NowPlaying',
        data() {
            return {
                movies:[]
            }
        },
        mounted() {
            this.$http.get('http://47.108.197.28:4000/api/movie/top250').then(res=>{
                res.data.res.forEach(item=>{
                    item.type=item.labels.join('|')
                })
                this.movies = res.data.res
            })
        },
        methods: {
            handleDetail(id){
                this.$router.push(`/detail?id=${id}`)
            }
        },
    }
</script>

<style scoped>
.nowPlaying{
    margin-top: 5vw;
}
.item{
    display: flex;
    margin-bottom: 5vw;
    padding:0 5vw;
    position: relative;
}
.pic{
    width: 22vw;
    height: 30vw;
    margin-right: 5vw;
}
.content{
    padding-top: 3vw;
}
.title{
    font-size: 6vw;
}
.rating,.type{
    color: #666;
    font-size: 4.5vw;
    margin-top: 2.5vw;
}
.rating span{
    color: #FFC332;
}
.type{
    width:53.6vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.btn{
    width: 16vw;
    height: 8vw;
    position: absolute;
    right: 5vw;
    top: 11vw;
    color: #FF5F16;
    border: 1px solid #FFB797;
    background-color: white;
}
</style>